﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PatternAdepter
{
    class Program
    {
        static void Main(string[] args)
        {
            Adapter adapter = new Adapter(new Speaker()); 
            Console.WriteLine(adapter.translator());
            Console.ReadKey();
        }
    }

    class Speaker
    {
        public string speak()
        {
            return "China";
        }
    }


    public interface ITranslator
    {
        string translator();
    }

    /// <summary>
    /// 组合方法适配 将原有实例传入适配器构造类  由类内部进行调用原函数方法并加以继续操作
    /// </summary>
    class Adapter : ITranslator
    {
        private Speaker _speaker = null;

        public Adapter( Speaker speaker )
        {
            _speaker = speaker;
        }

        public string translator()
        {
            string  result = _speaker.speak();  
            return result;
        }
    }


}
